﻿using CosmosSys = Cosmos.System;
using Cosmos.Core;
using Cosmos;

using Mirus.Corelib;
using Mirus.Corelib.Text;
using Mirus.Corelib.Text.Console;
using Mirus.Corelib.Version;
using Mirus.Sys.Compatability.VersionChecks;

namespace Mirus
{
    public class Kernel : CosmosSys.Kernel
    {
        Console c = new Console();

        protected override void BeforeRun()
        {
            //Make console functional here

            #region ConsoleSetup
            c.Clear();
            #endregion

            #region MirusBanner
            c.ChangeColor(System.ConsoleColor.Blue, 1);
            c.Print("Mirus " + Version.ReturnMirusVersion().ReturnVersionString() + "\n");
            #endregion

            #region Copyright
            c.ChangeColor(System.ConsoleColor.White, 1);
            c.Print("Copyright 2013, Joshua Beitler\n");
            c.Print("Mirus comes with ABSOLUTELY NO WARRANTY; for details\n");
            c.Print("type `show w`.  This is free software, and you are welcome\n");
            c.Print("to redistribute it under certain conditions; type `show c`\n");
            c.Print("for details.\n\n");
            #endregion

            #region Checks
            #region CosmosChecks
            c.Print(c.ConsoleUtil.ReturnPaddedString("Checking Cosmos...", 25));

            if (MinCosmosVersion.CheckVersion(Cosmos.System.Version.CosmosVersion()) == true)
            {
                c.ConsoleUtil.PrintOK();
            }
            else
            {
                c.ConsoleUtil.PrintFail();
            }
            #endregion

            #region RAM Checks
            c.Print(c.ConsoleUtil.ReturnPaddedString("Checking RAM...", 25));
            uint ram = Cosmos.Core.CPU.GetAmountOfRAM();

            if (ram <= 512)
            {
                c.ConsoleUtil.PrintWarning();
            }
            else if (ram > 512)
            {
                c.ConsoleUtil.PrintOK();
            }
            #endregion
            #endregion

            #region Begin Init
            // Do the rest of system bootstrapping

            // Load RAW
            // Load Mirus Filesystem with RAW

            // Load paging system
            // Load drivers
            // Load startup apps
            // Start system
            #endregion
        }

        protected override void Run()
        {
            
        }
    }
}
